import Vue from 'vue'
import Router from 'vue-router'
import routes from './router';
Vue.use(Router)
const router = new Router({
  // mode: 'history',
  routes
})
router.beforeEach((to, from, next) => {
  const savedState = JSON.parse(localStorage.getItem('tel'));
  if (to.path === '/login' || to.path === '/terms') {
    next();
  } else {
    if (!savedState) {
      next('/login');
    } else {
      next();
    }
  }
})
export default router
